﻿@{
    ViewBag.Title = "ForgotPassword";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>
    Forgot Password</h2>
<div class="div-forgot-pass">
    <div class="span6">
        <div class="moduletable">
            <h3>
                Remeber email and memory word</h3>
            <div class="content">
                <table class="table-data">
                    <tr>
                        <td class="td-label">
                            <div class="editor-label">
                                Email
                            </div>
                        </td>
                        <td class="td-control">
                            <div class="editor-field">
                                <input type="text" name="txtEmail" id="txtEmail" placeholder="Type your email..." />
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="td-label">
                            <div class="editor-label">
                                The memory word
                            </div>
                        </td>
                        <td class="td-control">
                            <div class="editor-field">
                                <input type="text" name="txtMemoryword" id="txtMemoryword" placeholder="Type your memory word when you register in the system..." />
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                            <p class="dvbutton">
                                <input type="button" value="Submit" name="btnSubmit" id="btnSubmit" />
                            </p>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    <div class="span6">
        <div class="moduletable">
            <h3>
                Remember something</h3>
            <div class="content">
                <table class="table-data">
                    <tr>
                        <td colspan="2">
                            If you forgot your email, please type some thing like your office, full name, or
                            something about you, we will send the information below to the administrator.
                        </td>
                    </tr>
                    <tr>
                        <td class="td-label">
                            <div class="editor-label">
                                Information
                            </div>
                        </td>
                        <td class="td-control">
                            <div class="editor-field">
                                <textarea id="txtInfor" name="txtInfor" cols="5" rows="10" placeholder="Type something about your here..."></textarea>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                            <p class="dvbutton">
                                <input type="button" value="Send" name="btnSend" id="btnSend" />
                            </p>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $("#btnSend").click(function () {
        $("#LoadingImage").show();
        $.ajax({
            url: '@Url.Action("AjaxSendEmailAdministrator", "Users")',
            type: 'POST',
            contentType: 'application/json',
            data: JSON.stringify({ content: $("#txtInfor").val() }),
            success: function (result) {
                if (result)
                    alert("Your message has been  sent to the Administrator of System. He will feedback as soon as possible");
                $("#LoadingImage").hide();
            }
        });
    });
    $("#btnSubmit").click(function () {
        $("#LoadingImage").show();
        $.ajax({
            url: '@Url.Action("AjaxResetPassAndSendEmailUser", "Users")',
            type: 'POST',
            contentType: 'application/json',
            data: JSON.stringify({ email: $("#txtEmail").val(), memoryword: $("#txtMemoryword").val() }),
            success: function (result) {
                if (result)
                    alert("Your password has been reset. Please check your email to detail");
                $("#LoadingImage").hide();
            }
        });
    });
</script>
